/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Pojo;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author jeferson
 */
@Entity
@Table(name = "TB_ARTISTA", catalog = "musical", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TbArtista.findAll", query = "SELECT t FROM TbArtista t"),
    @NamedQuery(name = "TbArtista.findByArtCodigo", query = "SELECT t FROM TbArtista t WHERE t.artCodigo = :artCodigo"),
    @NamedQuery(name = "TbArtista.findByArtNome", query = "SELECT t FROM TbArtista t WHERE t.artNome = :artNome")})
public class TbArtista implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ART_CODIGO")
    private Long artCodigo;
    @Basic(optional = false)
    @Column(name = "ART_NOME")
    private String artNome;
    @OneToMany(mappedBy = "proCodartista")
    private List<TbProduto> tbProdutoList;

    public TbArtista() {
    }

    public TbArtista(Long artCodigo) {
        this.artCodigo = artCodigo;
    }

    public TbArtista(Long artCodigo, String artNome) {
        this.artCodigo = artCodigo;
        this.artNome = artNome;
    }

    public Long getArtCodigo() {
        return artCodigo;
    }

    public void setArtCodigo(Long artCodigo) {
        Long oldArtCodigo = this.artCodigo;
        this.artCodigo = artCodigo;
        changeSupport.firePropertyChange("artCodigo", oldArtCodigo, artCodigo);
    }

    public String getArtNome() {
        return artNome;
    }

    public void setArtNome(String artNome) {
        String oldArtNome = this.artNome;
        this.artNome = artNome;
        changeSupport.firePropertyChange("artNome", oldArtNome, artNome);
    }

    @XmlTransient
    public List<TbProduto> getTbProdutoList() {
        return tbProdutoList;
    }

    public void setTbProdutoList(List<TbProduto> tbProdutoList) {
        this.tbProdutoList = tbProdutoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (artCodigo != null ? artCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TbArtista)) {
            return false;
        }
        TbArtista other = (TbArtista) object;
        if ((this.artCodigo == null && other.artCodigo != null) || (this.artCodigo != null && !this.artCodigo.equals(other.artCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return artNome;
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
